package com.ruoyi.movie.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.movie.domain.MovieVideo;
import com.ruoyi.movie.service.IMovieVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电影视频关联Controller
 *
 * @author ruoyi
 * @date 2025-01-29
 */
@RestController
@RequestMapping("/movie/videoRelation")
public class MovieVideoController extends BaseController
{
    @Autowired
    private IMovieVideoService movieVideoService;

    /**
     * 查询电影视频关联列表
     */
    @PreAuthorize("@ss.hasPermi('movie:videoRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(MovieVideo movieVideo)
    {
        startPage();
        List<MovieVideo> list = movieVideoService.selectMovieVideoList(movieVideo);
        return getDataTable(list);
    }

    /**
     * 导出电影视频关联列表
     */
    @PreAuthorize("@ss.hasPermi('movie:videoRelation:export')")
    @Log(title = "电影视频关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MovieVideo movieVideo)
    {
        List<MovieVideo> list = movieVideoService.selectMovieVideoList(movieVideo);
        ExcelUtil<MovieVideo> util = new ExcelUtil<MovieVideo>(MovieVideo.class);
        util.exportExcel(response, list, "电影视频关联数据");
    }

    /**
     * 获取电影视频关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('movie:videoRelation:query')")
    @GetMapping(value = "/{movieVideoId}")
    public AjaxResult getInfo(@PathVariable("movieVideoId") Integer movieVideoId)
    {
        return success(movieVideoService.selectMovieVideoByMovieVideoId(movieVideoId));
    }

    /**
     * 新增电影视频关联
     */
    @PreAuthorize("@ss.hasPermi('movie:videoRelation:add')")
    @Log(title = "电影视频关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieVideo movieVideo)
    {
        return toAjax(movieVideoService.insertMovieVideo(movieVideo));
    }

    /**
     * 修改电影视频关联
     */
    @PreAuthorize("@ss.hasPermi('movie:videoRelation:edit')")
    @Log(title = "电影视频关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieVideo movieVideo)
    {
        return toAjax(movieVideoService.updateMovieVideo(movieVideo));
    }

    /**
     * 删除电影视频关联
     */
    @PreAuthorize("@ss.hasPermi('movie:videoRelation:remove')")
    @Log(title = "电影视频关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieVideoIds}")
    public AjaxResult remove(@PathVariable Integer[] movieVideoIds)
    {
        return toAjax(movieVideoService.deleteMovieVideoByMovieVideoIds(movieVideoIds));
    }
}
